package com.example.bes018.single.ds.demo2.controller;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class RMITest {
    public static void main(String[] args) throws NamingException, SQLException {
        Properties props = new Properties();
        props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
        props.put(Context.PROVIDER_URL, "rmi://192.168.92.131:6600");
        props.put(Context.SECURITY_PRINCIPAL, "admin");
        props.put(Context.SECURITY_CREDENTIALS, "B#2008_2108#es");
        Context ctx = new InitialContext(props);
        DataSource ds = (DataSource) ctx.lookup("java:comp/env/db1");
        Connection connection = ds.getConnection();

    }
}
